package com.save.rpgsavedecode.util;

import org.apache.commons.lang3.StringUtils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.Base64;

public class Base64Util {
    static final Base64.Decoder decoder = Base64.getDecoder();
    static final Base64.Encoder encoder = Base64.getEncoder();

    public static byte[] encoderArray(byte[] bytes) {
        return encoder.encode(bytes);
    }

    public static byte[] decoderArray(byte[] bytes) {
        return decoder.decode(bytes);
    }

    public static String getString(byte[] bytes) throws UnsupportedEncodingException {
//        return new String(bytes, "UTF-8");
        return new String(bytes, "ISO-8859-1");
    }

    public static Character[] getChars(byte[] bytes) {
        Character[] characters = new Character[bytes.length];
        for (int i = 0; i < bytes.length; i++) {
            characters[i] = (char) bytes[i];
        }
        return characters;
    }



    public static void main(String[] args) throws IOException {
        byte i = 98;
        char c = (char) i;
        System.out.println(c);
    }


}
